{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 描述\n",
    "Python pass 是空语句，是为了保持程序结构的完整性。\n",
    "\n",
    "pass 不做任何事情，一般用做占位语句。\n",
    "\n",
    "# 语法\n",
    "Python 语言 pass 语句语法格式如下：\n",
    "```\n",
    "pass\n",
    "```\n",
    "\n",
    "# 实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当前字母 : P\n",
      "当前字母 : y\n",
      "当前字母 : t\n",
      "这是 pass 块\n",
      "当前字母 : h\n",
      "当前字母 : o\n",
      "当前字母 : n\n",
      "Good bye!\n"
     ]
    }
   ],
   "source": [
    "# 输出 Python 的每个字母\n",
    "for letter in 'Python':\n",
    "   if letter == 'h':\n",
    "      pass\n",
    "      print('这是 pass 块')\n",
    "   print('当前字母 :', letter)\n",
    " \n",
    "print(\"Good bye!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 其他实例\n",
    "在 Python 中有时候会看到一个 def 函数:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sample(n_samples):\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 解读\n",
    "该处的 pass 便是占据一个位置，因为如果定义一个空函数程序会报错，当你没有想好函数的内容是可以用 pass 填充，使程序可以正常运行。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
